<?

//Panneau de commerce pour la reception

TITRE_JEU("Panneau de commerce");



$query="SELECT  C.commerce_id,C.commerce_user_id1,C.commerce_user_id2,C.commerce_ress1,C.commerce_ress2,
C.commerce_approbation1,C.commerce_approbation2,C.commerce_unit1,C.commerce_unit2,C.commerce_choix1,
C.commerce_choix2,commerce_lorin1,commerce_lorin2
FROM tmp_commerce AS C,sduser_perso AS P WHERE C.commerce_user_id1=P.perso_id AND C.commerce_id=$art";
//                     0               1               2                3              4               5                6
$resultat=mysql_query($query);
$tmp=mysql_fetch_row($resultat);



IF ($_USER_PERSO!= $tmp[1] && $_USER_PERSO!= $tmp[2] ){  EXIT;}


   $_SESSION_VAR_ART=$art;
   SESSION_REGISTER("_SESSION_VAR_ART");


SWITCH($tmp[5]){
  CASE 0:
       $choix[0]='X';
  BREAK;

  CASE 1:
       $choix[0]='V';
  BREAK;

    }
SWITCH($tmp[6]){
  CASE 0:
       $choix[1]='X';
  BREAK;

  CASE 1:
       $choix[1]='V';
  BREAK;

    }



$query="SELECT ressourse_id,ressourse_icon, ressourse_name,ressourse_transfer FROM uressourse";
$resultat=mysql_query($query);

WHILE ($forum =mysql_fetch_array($resultat) ){
     $ressource_icon[$forum[0]]=$forum[1];
     $ressource_name[$forum[0]]=$forum[2];
     $ressource_transfert[$forum[0]]=$forum[3];
}


$query="SELECT ville_pic, ville_niv,ville_name,ville_loc_y,P.perso_name from sdville AS V, sduser_perso AS P WHERE ville_id=$tmp[8] AND P.perso_id=V.ville_proprio";
$resultat=mysql_query($query);
$ville=mysql_fetch_row($resultat);

 /*
$query="SELECT ville_pic, ville_niv,ville_loc_x,ville_loc_y from sdville where ville_id=$ville";
$resultat=mysql_query($query);
$ville=mysql_fetch_row($resultat);
   */

$ress1=explode("/",$tmp[3]);
$ress2=explode("/",$tmp[4]);


//Si il y a de l'argent dans la premiere partie
IF ($tmp[11]!=0){

   $res1.=DO_RESS($ressource_icon[$tmp[1]],$tmp[11],$ressource_name[$tmp[1]],1);


}

//Pour la premiere partie
$res=NULL;
FOREACH($ress1 as $tmp2){

        IF (!empty ($tmp2)){


               $tmp2=explode("-",$tmp2);
               $res1.=DO_RESS($ressource_icon[$tmp2[0]],$tmp2[1],$ressource_name[$tmp2[0]],$tmp2[0]);
         }  //Fin du IF (!empty ($tmp2)){
}//Fin du  FOREACH($ress1 as $tmp2){

//pour la deuxieme partie

IF ($tmp[12]!=0){
               $res2.=DO_RESS($ressource_icon[1],$tmp[12],$ressource_name[1],1);

}
//$res=NULL;

FOREACH($ress2 as $tmp2){

     IF (!empty ($tmp2)){
               $tmp2=explode("-",$tmp2);
               $res2.=DO_RESS($ressource_icon[$tmp2[0]],$tmp2[1],$ressource_name[$tmp2[0]],$tmp2[0]);
         }  //Fin du IF (!empty ($tmp2)){
}//Fin du  FOREACH($ress1 as $tmp2){



//SAvoir si il peut encore accepter la transaction:
IF ($tmp[6]!=1){
    //echo $tmp[11];
                  echo "---$tmp[4]-$tmp[12]";
      IF (empty($tmp[4])&& $tmp[12]==0){
            $MODIFIER="<A href=include.php?p=march_proposer>Proposer marcher</A>";
      }ELSE{
         //  $MODIFIER="<A href=include.php?p=march_mod&$SID >Modifier marcher</A>";
           $ACCEPTER="<form method=\"POST\" name=\"form_acc\"  action=\"../test/include.php?p=commerce_accepter\" target=\"frame_test\">
           <input name=\"article\" type=\"hidden\" id=\"article\" value=\"$art\">
           <input type=\"submit\" name=\"Submit\" value=\"Accepter marcher\"></form>";

      }
}


ECHO"</BR><CENTER><table width=98% border=0 cellpadding=0 cellspacing=0 bgcolor=#000000>
  <tr>
    <td width=100%> <table width=100% border=0 cellspacing=1>
        <tr>
          <td width=13% class=\"TD3\">
            <p align=center><u><strong>Unit&eacute;e</strong></u></p></td>
          <td width=15% class=\"TD3\"><div align=center><u><strong>Ville</strong></u></div></td>
          <td width=72% colspan=2 class=\"TD3\"><div align=center><strong><u>Option</u></strong></div></td>
        </tr>
        <tr>
          <td class=\"TD1\"><table width=100% border=0 cellspacing=0 cellpadding=0>
              <tr>
                <td><div align=center>Images</div></td>
              </tr>
              <tr>
                <td><div align=center>Nom</div></td>
              </tr>
            </table></td>
          <td class=\"TD1\"><table width=100% border=0 cellspacing=0 cellpadding=0>
              <tr>
                <td><div align=center><IMG SRC=../../images/batiment-carte/".$ville[0]."-".$ville[1].".png></div></td>
              </tr>
              <tr>
                <td><div align=center>$ville[2]</div></td>
              </tr>
              <tr>
                <td><div align=center>$ville[4]</div></td>
              </tr>
            </table></td>
          <td colspan=2 class=\"TD1\"><table width=100% border=0 cellspacing=0 cellpadding=0>
              <tr>
                <td><div align=center>$MODIFIER</div></td>
              </tr>
              <tr>
                <td><div align=center><A href=include.php?p=march_del&$SID >Annuler</A></div></td>
              </tr>
              <tr>
                <td><div align=center>$ACCEPTER</div></td>
              </tr>
            </table></td>
        </tr>
        <tr>
          <td colspan=2 class=\"TD3\"><div align=center><strong><u>Status</u></strong></div></td>
          <td class=\"TD3\"><div align=center><u><strong>Partis
              1 </strong></u></div></td>
          <td class=\"TD3\"><div align=center><u><strong>Partis
              2 </strong></u></div></td>
        </tr>
        <tr>
          <td class=\"TD1\"><div align=center>$choix[0]</div></td>
          <td class=\"TD1\"><div align=center>$choix[1]</div></td>
          <td class=\"TD1\">&nbsp;$res1</td>
          <td class=\"TD1\">&nbsp;$res2</td>
        </tr>
      </table>
      <div align=center><font color=#FFFF00><em></em></font><font color=#FFFF00><em></em></font><font color=#FFFF00><em></em></font><font color=#FFFF00><em></em></font></div></td>
  </tr>
</table></CENTER>
<p>";


?>
